<ion-view view-title="TODAY'S ORDER">
</ion-view>
<ion-side-menus>
    <!-- Left menu -->
    <ion-side-menu side="left" style="margin-top:44px;">
        <ul class="list">
            <li class="item">
                My Account
            </li>
            <li class="item">
                Delivery History
            </li>
            <li class="item">
                My Schedule
            </li>
            <li class="item">
                My Salary
            </li>
            <li class="item">
                Help & FAQ
            </li>
            <li class="item" ng-click="go('login')">
                Logout
            </li>
        </ul>
    </ion-side-menu>

    <ion-side-menu-content>

        <ion-content class="">
            <ion-refresher
                    pulling-text="Pull to refresh..."
                    on-refresh="doRefresh()">
            </ion-refresher>
            <h4><ionic-datepicker date="currentDate" min="minDate" max="maxDate" callback="datePickerCallback">
                <button class="button button-block button-positive"> {{ currentDate | date:'MMMM/dd/yyyy' }} </button>
            </ionic-datepicker></h4>
            <ion-list class="list" show-delete="false"
                      can-swipe="true">
                <ion-item class="item" ng-repeat="order in orders" ng-class="{'item-balanced':order.driver_confirmed == 1}" href="#/order-detail/{{order.increment_id}}">
                    <div >
                        <div>
                            {{order.store_name}} {{order.increment_id}} ({{order.total_qty_ordered | number : 0}} item<span ng-if="order.total_qty_ordered>1">s</span>)
                        </div>
                        <div>
                            Status:{{order.status}} {{order.created_at}}
                        </div>
                        <div>
                            <div>To:{{order.address.firstname}} {{order.address.lastname}} </div>
                            <div>{{order.address.telephone}}</div>
                            <div>{{order.address.street}} {{order.address.city}},{{order.address.region}}</div>
                            <div>Delivery window:{{order.delivery_window}}</div>
                        </div>
                    </div>
                    <div ng-if="order.order_completed == 0">
                        <ion-option-button class="button-positive"
                                           ng-click="confirmOrder(order.order_id)" ng-if="order.driver_confirmed == 0">
                            Confirm
                        </ion-option-button>
                        <ion-option-button class="button-info"
                                           ng-click="disprocessOrder(order.order_id)" ng-if="order.driver_confirmed == 1">
                            Disprocess
                        </ion-option-button>
                        <ion-option-button class="button-royal"
                                           ng-click="goGoogleMap(order.address.street,order.address.city,order.address.region)">
                            Map
                        </ion-option-button>
                    </div>
                </ion-item>

            </ion-list>
        </ion-content>

    </ion-side-menu-content>

</ion-side-menus>



